package com.dmwork.service.interaction.controller.front;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dmwork.common.base.result.R;
import com.dmwork.service.interaction.entity.WorkCollectGroup;
import com.dmwork.service.interaction.service.WorkCollectGroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@Api(description = "全局收藏分组管理")
@RequestMapping("/front/dm_work/interaction/collect_group")
@RestController
public class FrontWorkCollectGroupController {

    @Autowired
    private WorkCollectGroupService workCollectGroupService;

    @ApiOperation("获取指定用户公开的收藏分组")
    @GetMapping("get_group_list/{customerId}")
    public R getGroupList(@ApiParam(value = "用户id", required = true) @PathVariable("customerId") String customerId) {
        QueryWrapper<WorkCollectGroup> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("customer_id", customerId).eq("public_status", WorkCollectGroup.PUBLIC);
        List<WorkCollectGroup> collectGroupList = workCollectGroupService.list(queryWrapper);
        return R.ok().data("items", collectGroupList);
    }

}
